<? /* license

BilugCMS (http://www.bilug.it) - Content Management System for dynamic web sites
Copyright (C) 2005-2008  Federico Villa and Alessio Loro Piana

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For reference, contact bilugcms@vilnet.it


license */ ?>
<?
require_once("funzioni.php");
$d = apici($_GET['d']); 
?>
<div class="contenitore">
	<h3 class="Cap">Gallerie Disponibiili in : <?=str_replace("_"," ",$d)?></h3>	
	<ul>	
<?
$dir='../gals/'.$d;
$filename = array();
if ($handle = @opendir($dir)) 
{
   while (false !== ($file = readdir($handle))) 
   { 
		if ($file != '.' and $file != '..' and filetype($dir."/".$file) == 'dir') 
   		$filename[] =$file;   	
   }
   closedir($handle);
   
   if (isset($filename) and count($filename)>0 )
   {
   	$filtro = array("image/jpg","image/jpeg","image/gif","image/png");
   	natcasesort($filename);
   	foreach ($filename as $key => $value)
   	{
      	echo "<li><a class=\"Cap\" href=\"index.php?pag=../utility/galleria.php&amp;d=$value&amp;argo=$d\">".
         str_replace("_"," ",substr($value,strpos($value,"_")+1));
         //Calcolo Numero Immagini
         $directory =$dir.'/'.$value.'/';
			$filed = $value;
			if ($handle1 = @opendir($directory)) 
			{
				//setto l'array delle immagini		
				$conta = 0;				
				while (false !== ($file = readdir($handle1)))
				{
					$dati= getimagesize($directory . $file);		
					if (in_array($dati['mime'],$filtro)) $conta++;
   			}
				closedir($handle1);
				echo "(".$conta.")";
			}
         echo "</a><div class=\"descgal\"> ";
         @include ($dir."/".$filed."/".$filed.".txt");
         echo "</div></li>";	   	
   	}
   }
   else echo "<li><h3>Nessuna Galleria Disponibile</h3></li>";	 
}
else echo "<li><h3>Cartella Gallerie non valida</h3></li>";
?>
	</ul>
</div>

